package com.yixun.qfbao.util;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;

public class QRCodeUtil {
	 public static BufferedImage createQRCode(String content) throws WriterException, IOException {  
	        int width = 200; // 图像宽度  
	        int height = 200; // 图像高度  
	        Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();  
	        hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");  
	        BitMatrix bitMatrix = new MultiFormatWriter().encode(content,  
	                BarcodeFormat.QR_CODE, width, height, hints);// 生成矩阵  
	        BufferedImage bufferedImage=MatrixToImageWriter.toBufferedImage(bitMatrix);
	        return bufferedImage;
	 } 
}
